<?php
namespace app\controller;

use script\Db;

use app\item\Paper as PaperItem;
use app\item\Test as TestItem;
// use script\Config;
use config\Index;
use config\Db as Conf;

class Test
{
    public function index(){
        // echo "<pre>";
        $conf = new Conf();
        $where = [
            ['id', '=', '111'],
            ['user_id', '=', '22'],
            ['cat_id', '=', '333'],
        ];
        // $conf['dev'];
        $db = Db::connect();
        var_dump($db);
        
    }
    public function indexBat()
    {
        echo "<pre>";
        $option = [
            'host' 		=> '127.0.0.1',
            'user' 		=> 'root',
            'pass' 		=> 'root',
            'dbname' 	=> 'spider',
            'port' 		=> 3306,
            'charset' 	=> 'utf8'
        ];

        $data = file_get_contents('./public/paper-2-2-534.txt');
        $res = json_decode($data);

        $paper = [];
        $paperItem = new PaperItem();
        // 循环试卷列表
        foreach ($res as $key => $value) {
            echo '<pre>';
            $paper_data = $paperItem->paperSingle((array)$value->_meta);
            // 封装试卷数据
            array_push($paper, $paper_data);
        }
        // var_dump($paper[0]);die;
        // $db = Db::connect($option)->table('p_paper')->insert($paper[0]);
        
        // $db = Db::connect($option)->table('p_paper')->addAll($paper);

        // $db = Db::connect($option)->table('p_paper')->insertAll($paper);

        // $where = [
        //     ['id', '=', '111'],
        //     ['user_id', '=', '22'],
        //     ['cat_id', '=', '333'],
        // ];
        // $db = Db::connect($option)->table('p_paper')->where($where)->select();

        
    }

}